package com.sxt.demo.djiapplication.utils

import android.content.Context
import com.sxt.demo.djiapplication.dao.DaoMaster
import com.sxt.demo.djiapplication.dao.DaoSession

object DbManager {

    private lateinit var mDaoMaster: DaoMaster

    private lateinit var mDaoSession: DaoSession

    @JvmStatic
    fun initDb(context: Context) {
        // 准备需要连接的数据库
        val devOpenHelper = DaoMaster.DevOpenHelper(context, "flight.db")
        // 创建数据库链接
        mDaoMaster = DaoMaster(devOpenHelper.writableDatabase)
        // 生成对应的数据库会话
        mDaoSession = mDaoMaster.newSession()
    }

    @JvmStatic
    fun getDaoSession(): DaoSession {
        return mDaoSession
    }

}